﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLBenhVien
{
    public partial class frmDangNhap : Form
    {
        public frmDangNhap()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btLogin_Click(object sender, EventArgs e)
        {
            doLogin();
        }

        private void Login_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                doLogin();
            }
        }

        private void doLogin()
        {

            DBOUser u = new DBOUser(txtUsername.Text, txtPassword.Text);
            if (u.isValid() == null)
            {
                MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu");
                txtUsername.ResetText();
                txtPassword.ResetText();
                txtUsername.Focus();
            }
            else
            {
                frmManHinhChinh mf = new frmManHinhChinh(u);
                mf.Show();
                this.Hide();
            }
        }
    }
}
